"""
操作日志记录
"""

from logzero import LogFormatter, setup_default_logger, logfile
import logging
from Common.log.logconfig import Config


def logger_config(logpath):
    """日志配置设置"""

    # 控制台输出格式
    hand_format = LogFormatter(fmt=Config.handler_format,
                               datefmt=Config.data_style)
    setup_default_logger(formatter=hand_format)

    # 文件输出格式
    formatter = logging.Formatter(Config.file_format, Config.data_style)
    logfile(f'{logpath}/debug.log',
            formatter=formatter,
            maxBytes=Config.maxBytes,
            backupCount=Config.backupCount,
            encoding='utf-8',
            loglevel=Config.level)
